from .models import Account
from django.contrib.auth.models import User


class Mybackend:
    def authenticate(self, username=None, password=None):
        try:
            user = Account.objects.get(user_name=username)
        except User.DoesNotExist:
            return None
        else:
            if user.password == password:
                return user
            else:
                return None

    def get_user(self, user_id):
        try:
            user = Account.objects.get(pk=user_id)
            return user
        except User.DoesNotExist:
            return None

